<?php
//OJB: Check if for excel export process
ob_start();
?>
<table class="table" id="repayment_detail_flex">
    <thead>
    <tr>
        <th>Month</th>
        <th>Repayment Schedule</th>
        <th>Expected <?php echo $json_data['Sale']['currency']?></th>
        <th>Actual  <?php echo $json_data['Sale']['currency']?></th>
        <th>Outstanding  <?php echo $json_data['Sale']['currency']?></th>
    </tr>
    </thead>
    <tbody>
    <?php
    if(isset($json_data['Sale'])){
        $data = $json_data['Sale']['repayment'];
        foreach($data as $row){
            ?>
        <tr>
            <td><?php echo $row[0]?></td>
            <td><?php echo $row[1]?></td>
            <td><?php echo $row[2]?></td>
            <td><?php echo $row[3]?></td>
            <td><?php echo $row[4]?></td>
        </tr>
            <?php
        }
    }
    ?>
    </tbody>
</table>
<?php
    $content = ob_end_flush();

    $filename = $file_name;
    $filename = str_replace(array(' ', '/', '\\'), '', $filename);
    $filename .= "_Export.xls";
    header('Content-type: application/ms-excel');
    header('Content-Disposition: attachment; filename='.$filename);
    echo $content;
    die();

?>